package com.bocai.freeman.view.adapter;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.bocai.freeman.R;

import butterknife.ButterKnife;

/**
 * Created by win7 on 2016/5/20.
 */
public class LatelyPersonAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
    private Context mContext;
    private OnItemClickLitener mOnItemClickLitener;

    public LatelyPersonAdapter(Context context) {
        this.mContext = context;
    }

    public interface OnItemClickLitener {
        void onItemClick(View view, int position, int itemType);
    }

    public void setOnItemClickLitener(OnItemClickLitener mOnItemClickLitener) {
        this.mOnItemClickLitener = mOnItemClickLitener;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(mContext).inflate(R.layout.item_lately_person, parent, false);
        return new ViewHoder(view);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        if (mOnItemClickLitener != null) {
            holder.itemView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    int pos = holder.getLayoutPosition();
                    mOnItemClickLitener.onItemClick(holder.itemView, pos, 1);
                }
            });
        }
    }

    @Override
    public int getItemCount() {
        return 10;
    }

    public class ViewHoder extends RecyclerView.ViewHolder {

        public ViewHoder(View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
